<html class="ios">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="theme-color" content="#2196f3">
    <title>{:config('web_site_title')}</title>
    <link rel="stylesheet" href="__PUBLIC__/css/framework7.min.css">
    <link rel="stylesheet" href="__PUBLIC__/css/my-app.css?time=2">
    <link rel="stylesheet" href="__PUBLIC__/css/font/iconfont.css">
    {block name='css'}{/block}
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.2.1.4.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/lib/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/js/lib/layui/css/layui.css"/>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <link rel="stylesheet" href="__STATIC__/new/swiper-bundle.min.css">

</head>
<body>
<div id="app">
    <div class="statusbar"></div>
    {block name='body'}{/block}
</div>

<script>
    function getRegion(self, index, sid) {
        var id;
        if (typeof self == 'object') {
            id = self.value;
            if (id <= 0) {
                return false;
            }
        } else {
            id = self;
        }
        var title,field;
        switch (index) {
            case 0:
                title = '省';
                field = 'sheng_id';
                $('select[name=city]').html('<option value="">请选择市</option>');
                $('select[name=area]').html('<option value="">请选择区</option>');
                break;
            case 1:
                title = '市';
                field = 'city_id';
                $('select[name=area]').html('<option value="">请选择区</option>');
                break;
            case 2:
                title = '区';
                field = 'area_id';
                break;
        }

        if (!sid) {
            var sca_name = '';
            $('.js-region select').each(function (i, n) {
                if ($(n).find('option').length > 1) {
                    sca_name += $(n).find('option:selected').text() + ',';
                }
            });
            $('input[name=sca_name]').val(sca_name.substr(0, sca_name.length - 1));
        }
        if (!title) {
            return false;
        }
        $.post("{:url('Index/getAjaxRegion')}", {id:id}, function(data){
            if(data.status == 'y'){
                var str = '<option value="">请选择'+title+'</option>';
                for(var i in data.data){
                    str += '<option value="'+data.data[i].id+'" '+(sid==data.data[i].id ? 'selected="true"' : '')+'>'+data.data[i].title+'</option>';
                }
                $("select[name='"+field+"']").html(str);
            }else{
                messageToast(data.info)
            }
        }, 'json');
    }
    function getGoodsList(cate_id, order, keywords) {
        var total = $('.home-goods-ul .li').length;
        if (total % 10 != 0) {
            return false;
        }

        if ($('.loading').is(':visible') || $('.no-more').is(':visible') || $('.no-data').is(':visible')) {
            return false;
        }
        $('.loading').show();

        var p = total / 10;
        $.post("{:url('index/getGoodsList')}", {page:p+1,cate_id:cate_id,order:order,keywords:keywords,handle:$('.js-page').attr('data-handle')}, function(data){
            var str = '';
            $('.loading').hide();
            if (data.data.data.length > 0) {
                $.each(data.data.data, function(i,n){
                    str += '<div class="li">\n' +
                        '    <div class="m">\n' +
                        '        <a href="{:url("index/index/goods")}?id='+n.id+'" class="external" ><img src="'+n.img+'" class="lazy lazy-fade-in" ></a>\n' +
                        '        <p class="p1">'+n.title+'</p>\n' +
                        '        <p class="p2">￥'+n.unit_price+'</p>\n' +
                        '    </div>\n' +
                        '</div>';
                });
                if (data.data.data.length < 10) {
                    $('.no-more').show();
                }
                $(str).appendTo($('.home-goods-ul'));
            } else {
                if (total > 0) {
                    $('.no-more').show();
                } else {
                    $('.no-data').show();
                }
            }
        }, 'json');
    }
    
</script>
<script type="text/javascript" src="__PUBLIC__/js/framework7.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/my-app.js"></script>
<script>
    $(function(){
        var title = $('.navbar .center').text();
        if (title) {
            $(document).attr('title', title);
        }
    });
</script>
{block name='js'}

{/block}

</body>
</html>